<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
key=request.QueryString("key")
mark=request.QueryString("mark")
typevalue=request.QueryString("typevalue")
search=request.QueryString("search")
if search="搜索" then
	  if key<>"" then
			sqlsearch=" and ([order] like '%"&key&"%' or order2 like '%"&key&"%' or order3 like '%"&key&"%' or order4 like '%"&key&"%' or [content] like '%"&key&"%')"
	  end if
	  if mark<>"" then
			if mark="0" then sqlsearch=sqlsearch+" and [order]='0' and order2='0' and order3='0' and order4='0'"
			if mark="1" then sqlsearch=sqlsearch+" and ([order]<>'0' or order2<>'0' or order3<>'0' or order4<>'0')"
	  end if
	  if typevalue<>"" then
            sqlsearch=sqlsearch+" and kid="&typevalue&""
      end if
end if
'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by fid asc,Number asc) as sortid,* From Seat) as TempTable where 1=1 "&sqlsearch&""
Pager_Pagesize=16 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" id,fid,kid,Number,[order],order2,order3,order4,content,sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<style>body {background-color: #eaece1;}</style>
</head>

<body>
<div class="main">
  <div class="main-title">查看</div>
  <div class="main-content">
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6" align="center">
    <form name="form" method="get" action="">
    订单号<input name="key" type="text" id="key" value="<%=key%>" maxlength="50" />
    <select name="mark" id="mark">
      <option value="">位置</option>
      <option value="0" <%if mark="0" then response.Write " selected"%>>无货</option>
      <option value="1" <%if mark="1" then response.Write " selected"%>>有货</option>
    </select>
    <select name="typevalue" id="typevalue">
    <option value="">库房</option>
    <%
					  set rsm=server.CreateObject("adodb.recordset")
					  sql="select * from Storeroom"
					  rsm.open sql,conn,1,3
					  if not rsm.eof then
					  do while not rsm.eof
					  %>
      <option value="<%=rsm("id")%>"<%if typevalue=trim(rsm("id")) then response.Write " selected"%>><%=rsm("title")%></option>
       <%
					  rsm.movenext
					  loop
					  rsm.close
					  set rsm=nothing
					  end if		 
					  %>
    </select>
    <input type="submit" name="search" value="搜索" />
    </form>
    </td>
    </tr>
    </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="14%" align="center" bgcolor="#FFFFFF"><strong>订单号</strong></td>
    <td width="14%" align="center" bgcolor="#FFFFFF"><strong>订单号</strong></td>
    <td width="14%" align="center" bgcolor="#FFFFFF"><strong>订单号</strong></td>
    <td width="14%" align="center" bgcolor="#FFFFFF"><strong>订单号</strong></td>
    <td width="10%" align="center" bgcolor="#FFFFFF"><strong>位置</strong></td>
    <td width="10%" align="center" bgcolor="#FFFFFF"><strong>货架</strong></td>
    <td width="9%" align="center" bgcolor="#FFFFFF"><strong>库房</strong></td>
    <td width="10%" align="center" bgcolor="#FFFFFF"><strong>备注</strong></td>
    </tr>
    <%do while not Rs.eof%>
  <tr title="<%=rs("content")%>">
    <td align="center" bgcolor="#FFFFFF"><input name="order" type="text" class="kufang" value="<%=rs("order")%>" />
    </td>
    <td align="center" bgcolor="#FFFFFF"><input name="order2" type="text" class="kufang" value="<%=rs("order2")%>" /></td>
    <td align="center" bgcolor="#FFFFFF"><input name="order3" type="text" class="kufang" value="<%=rs("order3")%>" /></td>
    <td align="center" bgcolor="#FFFFFF"><input name="order4" type="text" class="kufang" value="<%=rs("order4")%>" /></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("Number")%></td>
    <td align="center" bgcolor="#FFFFFF"><%
    set rss=conn.execute("select Number from Shelf where id="&rs("fid"))
    if not rss.eof then
    response.write rss("Number")
    end if
    set rss=nothing
    %></td>
    <td align="center" bgcolor="#FFFFFF"><%
    set rss=conn.execute("SELECT Storeroom.title FROM Shelf RIGHT OUTER JOIN Storeroom ON Shelf.Fid = Storeroom.id where Shelf.id="&rs("fid")&"")
    if not rss.eof then
    response.write rss("title")
    end if
    set rss=nothing
    %></td>
    <td align="center" bgcolor="#FFFFFF"><a href="edit.asp?id=<%=rs("id")%>">签写</a>
    <input name="checkbox" type="hidden" value="<%=rs("id")%>" />
    </td>
    </tr>
    <%
	Rs.movenext
	loop
	Rs.close
	Set Rs=nothing
	%>
    <tr>
      <td colspan="8" align="center" bgcolor="#FFFFFF" class="page">
<input type="submit" name="button" id="button" value="保存" /> 
      </td>
    </tr>
    </form>
    <tr>
    <td colspan="8" align="center" bgcolor="#FFFFFF" class="page">　
      <%
	siteurl=request.servervariables("document_name")
	%>
    <form action="<%=siteurl%>" method="get">
    共 <%=Pager_TotalRecord%> 条 第<%=CurrentPage%>页 / 共 <%=Pager_PageCount%> 页
		<%
		pageurl="key="&key&"&mark="&mark&"&typevalue="&typevalue&"&search="&search&"&"
		if CurrentPage=1 then
			response.Write(" 首页 ")
			response.Write(" 上一页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page=1'>首页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage-1) &"'>上一页</a> ")
		end if
		%>
		<%
		if Clng(CurrentPage)=Clng(Pager_PageCount) then
			response.Write(" 下一页 ")
			response.Write(" 尾页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage+1) &"'>下一页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& Pager_PageCount &"'>尾页</a> ")
		end if
		%>
		&nbsp;
		<input name="page" type="text" value="<%=CurrentPage%>" size="1" maxlength="10" />
        <input type="submit" name="button" value="跳转" />
        <input type="hidden" name="key" value="<%=key%>" />
        <input type="hidden" name="mark" value="<%=mark%>" />
        <input type="hidden" name="typevalue" value="<%=typevalue%>" />
        <input type="hidden" name="search" value="搜索" />
        </form>
      </td>
    </tr>
  </table>
</div>
</div>
</body>
</html>
<%
checkbox=request.Form("checkbox")
if checkbox<>"" then	
	if request.Form("button")="保存" then
		checkbox=replace(checkbox," ","")
        checkbox=Split(checkbox,",")
        order=replace(Request("order")," ","")
        order=Split(order,",")
		order2=replace(Request("order2")," ","")
        order2=Split(order2,",")
		order3=replace(Request("order3")," ","")
        order3=Split(order3,",")
		order4=replace(Request("order4")," ","")
        order4=Split(order4,",")
        For i=LBound(checkbox) To UBound(checkbox) 
        Set rs = Server.CreateObject("ADODB.Recordset")
        sql= "Select * from Seat where id ="&checkbox(i)&""
        rs.open sql,conn,1,3
        rs("order")=order(i)
		rs("order2")=order2(i)
		rs("order3")=order3(i)
		rs("order4")=order4(i)
        rs.Update
        Next
	end if
	response.Redirect "view.asp?page="&request.QueryString("page")&""
end if
%>